#include "LocalScene.h"
#include "Utils/LogUtil.h"
#include "LocalEntity.h"
#include "Utils/StringUtil.h"
#include "Game/Component/Model.h"
#include "Render/RenderState.h"
#include "Render/Imgui/imgui.h"
#include "Math/Random.h"


void LocalScene::OnInit()
{
	mShowSphere = true;

	mCoordinateProcess = GetProcess<CoordinateProcess>("CoordinateProcess");
	mRandomProcess = GetProcess<RandomProcess>("RandomProcess");
	mHelfSphereProcess = GetProcess<HelfSphereProcess>("HelfSphereProcess");

	GeometryGenerator geometryGenerator;

	GeometryGenerator::MeshData sphereData = geometryGenerator.CreateSphere(1.f, 20, 20);

	LocalEntity* sphereEntity = CreateEntity<LocalEntity>("sphere");
	sphereEntity->AddComponent<Model>(sphereData);

	mRandomProcess->mMaxFrame = 200;
	mHelfSphereProcess->ResetState();
}

void LocalScene::OnExit()
{

}

void LocalScene::OnTick(float deltaTime)
{

}

void LocalScene::OnImgui()
{
	GameScene::OnImgui();

#if 1

	ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);

	ImGui::Begin("Option");

	if (ImGui::Checkbox("Show Sphere", &mShowSphere))
	{
		if (mShowSphere)
		{
			mCoordinateProcess->UpdateColorRenderTarget("LocalProcess", "ColorRenderTarget");
		}
		else
		{
			mCoordinateProcess->UpdateColorRenderTarget("RandomProcess", "ColorRenderTarget");
		}
	}

	if (ImGui::InputInt("max frame", &mRandomProcess->mMaxFrame, 10, 10))
	{
		mRandomProcess->mFrame = 0;
	}

	if (ImGui::InputFloat("space", &mRandomProcess->mSpace, 0.0001, 0.001)) { mRandomProcess->mFrame = 0; }

	if (ImGui::RadioButton("RandomLcg", &mRandomProcess->mRandMode, 0)) { mRandomProcess->mFrame = 0; }
	if (ImGui::RadioButton("RandomCo", &mRandomProcess->mRandMode, 1)) { mRandomProcess->mFrame = 0; }
	if (ImGui::RadioButton("Hammersley2d", &mRandomProcess->mRandMode, 2)) { mRandomProcess->mFrame = 0; }
	if (ImGui::RadioButton("Sobol", &mRandomProcess->mRandMode, 3)) { mRandomProcess->mFrame = 0; }
	if (ImGui::RadioButton("Sobol W", &mRandomProcess->mRandMode, 4)) { mRandomProcess->mFrame = 0; }
	if (ImGui::RadioButton("WangHash", &mRandomProcess->mRandMode, 5)) { mRandomProcess->mFrame = 0; }



	ImGui::End();

#endif
}
